import request from '@/utils/request'

export const getAddressList = () => {
  return request.get('/address/list')
}

export const getDefaultAddressId = () => {
  return request.get('/address/defaultId')
}

export const addAddress = (name, phone, region, detail) => {
  return request.post('/address/add', {
    form: {
      name, phone, region, detail
    }
  })
}

export const editAddress = (addressId, name, phone, region, detail) => {
  return request.post('/address/edit', {
    addressId,
    form: {
      name, phone, region, detail
    }
  })
}

export const setDefaultAddress = (addressId) => {
  return request.post('/address/setDefault', {
    addressId
  })
}

export const removeAddress = (addressId) => {
  return request.post('/address/remove', {
    addressId
  })
}

export const getAddressDetail = (addressId) => {
  return request.get('/address/detail',
    {
      params: {
        addressId
      }
    })
}
